home *** CD-ROM | disk | FTP | other *** search
- Path: news.cs.indiana.edu!djacobso@cs.indiana.edu
- From: "dan j" <djacobso@cs.indiana.edu>
- Newsgroups: comp.lang.c++
- Subject: Default values
- Date: Fri, 19 Apr 1996 08:50:13 -0500 (EST)
- Organization: Computer Science, Indiana University
- Message-ID: <26418@829921816>
- NNTP-Posting-Host: news.cs.indiana.edu
-
- Is it somehow possible to use a class member variable as a default
- value to a member function? When, if ever, can variables serve as
- default values? For instance,
-
- class tree {
- tree_node * root;
-
- public:
- ...
- foo(tree_node * ptr = root) { (recursive); }
- ...
- };
-
- g++ (SunOS) says 'root' is not defined in this scope.
-
- A special function foo2() called with 'root' serves the purpose:
-
- foo(tree_node * ptr) { (recursive); }
- foo2(void) { foo(root); }
-
- But what is a better way to handle this?
-
-
- dan j
-